package cn.xorange.commons.system.mapper.system;

import cn.xorange.commons.data.core.mapper.MBaseMapper;
import cn.xorange.commons.system.entity.system.SysUserRole;
import com.alibaba.fastjson2.JSONArray;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * @author : yangjian
 * @date : 2022/3/22
 */
@Mapper
public interface SysUserRoleMapper extends MBaseMapper<SysUserRole> {

    @Select("select role_id from sys_user_role where user_id = #{userId}")
    List<Long> selectUserRoleIds(@Param("userId") Long userId);

    @Delete("<script> delete from sys_user_role where user_id in " +
            "<foreach item = 'id' collection = 'userIds' separator=',' open='(' close=')'>" +
            "#{id}" +
            "</foreach></script>")
    int delByUserIds(@Param("userIds")Long[] userIds);
}
